package com.itheima.filter;

import javax.servlet.*;
import java.io.IOException;


//@WebFilter(filterName ="encondingFilter",urlPatterns = "/*")
public class EncondingFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        //设置编码格式
        servletRequest.setCharacterEncoding("UTF-8");
        servletResponse.setContentType("text/html;charset=UTF-8");

        //调用链放行
        filterChain.doFilter(servletRequest,servletResponse);

    }
    @Override
    public void destroy() {

    }
}
